import java.io.*;

public class Test3 {
    public static void main(String[] args) {
        String fileName = "D:\\Java\\Hello.txt";

        try {
            FileWriter writer = new FileWriter(fileName, true);//已有文件后续写而不是完全替代

            writer.write("Hello!\n");
            writer.write("This is my first text file,\n");
            writer.write("You can see how this is done.\n");
            writer.write("输入一行中文也可以\n");
            writer.write("haha\n");
            writer.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
